<template>
  <el-container style="height: 100vh;">
    <!-- 左侧导航栏 -->
    <el-aside width="220px" style="background-color: #545c64;">
      <!-- 系统名称 -->
      <div class="system-title">
        <span>新闻动态分析系统</span>
      </div>

      <!-- 导航菜单 -->
      <el-menu
          :default-active="activeIndex"
          class="el-menu-vertical"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          :router="true"
      >
        <el-menu-item index="/home">
          <el-icon><Menu /></el-icon>
          <span>首页</span>
        </el-menu-item>
        <el-menu-item index="/impression">
          <el-icon><data-line /></el-icon>
          <span>曝光日志</span>
        </el-menu-item>
        <el-menu-item index="/change">
          <el-icon><trend-charts /></el-icon>
          <span>变化查询</span>
        </el-menu-item>
        <el-menu-item index="/statistics">
          <el-icon><pie-chart /></el-icon>
          <span>统计查询</span>
        </el-menu-item>
        <el-menu-item index="/analysis">
          <el-icon><DataAnalysis /></el-icon>
          <span>分析与推荐</span>
        </el-menu-item>
        <el-menu-item index="/query">
          <el-icon><Search /></el-icon>
          <span>查询日志</span>
        </el-menu-item>
      </el-menu>
    </el-aside>

    <!-- 主内容区 -->
    <el-container>
      <!-- 顶部导航 -->
      <el-header style="border-bottom: 1px solid #e6e6e6; display: flex; justify-content: space-between; align-items: center;">
        <div class="header-left">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>{{ currentRouteName }}</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
      </el-header>

      <!-- 主要内容 -->
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script lang="ts" setup>
import { ref, computed } from 'vue';
import { useRoute } from 'vue-router';
import {
  ElContainer,
  ElAside,
  ElMenu,
  ElMenuItem,
  ElHeader,
  ElMain,
  ElBreadcrumb,
  ElBreadcrumbItem,
  ElIcon,
} from 'element-plus';
import {
  Menu,
  DataLine,
  PieChart,
  TrendCharts,
  DataAnalysis,
  Search
} from '@element-plus/icons-vue';

const route = useRoute();

const activeIndex = computed(() => route.path);

const currentRouteName = computed(() => {
  const routeNameMap: Record<string, string> = {
    '/home': '首页',
    '/impression': '曝光日志',
    '/change': '变化查询',
    '/statistics': '统计查询',
    '/analysis': '分析与推荐',
    '/query': '查询日志'
  };
  return routeNameMap[route.path] || '首页';
});
</script>

<style scoped>
.system-title {
  height: 60px;
  line-height: 60px;
  color: white;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  border-bottom: 1px solid #666;
}

.el-menu-vertical {
  border-right: none;
}
</style>